<template>
	<view class="order">
		<!-- tab 栏 -->
		<view class="tabBox">
			<view class="card" :style="{backgroundImage:'url('+baseUrl+'static/index/pull.png'+')'}">
				<view class="card_1">
					<view class="my">员工总数（总计）</view>
					<view class="curr">{{totalStaff||0}}</view>
				</view>
				<view class="card_2" @tap.stop="goMoney">
					申请列表
				</view>
			</view>
		</view>
		<!-- 列表 -->
		<view class="listBox">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="list_l">
					<image :src="item.avatar" mode=""></image>
					<view class="list_l_r">
						<view class="name">{{item.name||''}}</view>
						<view class="name">
							<view class="">
								{{item.staff_mobile||''}}
							</view>
							<view class="icon" v-if="item.staff_mobile" @tap.stop="callPhone(item.staff_mobile)">
								<image src="../static/images/index/call.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
				<view class="list_r">
					<view class="time">{{item.time||''}}</view>
					<view class="btn" @tap.stop="goTeam(item.id)">成员详情</view>
				</view>
			</view>
		</view>

		<!-- 提示栏 -->
		<view class="more">{{isText}}</view>

	</view>
	</view>
</template>

<script>
	import config from '@/common/config/config';
	export default {
		data() {
			return {
				baseUrl: config.baseurl,
				page: 1,
				list: [],
				isText: '',
				last_page: 1,
				totalStaff:''
			};
		},
		onLoad() {

		},
		onShow() {
			this.init()
			this.loadData()
			this.getList()
		},
		methods: {
			init(){
				this.list = []
				this.page = 1
				this.isText = ''
			},
			// 获取员工总人数
			async loadData() {
				await uni.request({
					url: '/wanlshop/user/refresh',
					method: 'POST',
					success: res => {
						this.totalStaff = res.data.totalStaff
					}
				});
			},
			// 获取员工列表
			async getList() {
				let that = this

				await uni.request({
					url: '/wanlshop/user/staffList',
					data: {
						page: this.page
					},
					success: res => {
						that.list = that.list.concat(res.data.data)
						that.last_page = res.data.last_page
						res.data.total == that.list.length ? that.isText = '暂无数据' : that.isText = ''
						console.log(res.data, 'that.list')
					}
				});
			},
			// 点击拨号
			callPhone(phoneNumber) {
				if (!phoneNumber) return
				uni.makePhoneCall({
					phoneNumber,
				});
			},
			// 申请列表
			goMoney() {
				uni.navigateTo({
					url: '/pages/employList'
				})
			},
			// 成员详情
			goTeam(id) {
				uni.navigateTo({
					url: `/pages/teamMember?id=${id}&&type=1`
				})
			},
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
				that.getList()
			}
		}

	}
</script>

<style lang="less">
	page {
		background-color: #fff;
	}

	.u-tab-bar {
		display: none !important;
	}

	.more {
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		margin: 30rpx auto;
		padding-bottom: 50rpx;
	}

	.order {
		width: 100vw;

		.tabBox {
			width: 100%;
			height: 180rpx;
			background: #fff;
			position: sticky;
			top: 0;
			z-index: 1000;
			padding-bottom: 20rpx;

			.card {
				width: 94%;
				height: 100%;
				background-size: 100% 100%;
				border-radius: 20rpx;
				margin: 20rpx auto;
				display: flex;
				padding: 20rpx 20rpx 20rpx 50rpx;
				justify-content: space-between;

				.card_1 {
					color: #fff;
					align-items: center;

					.my {
						font-weight: 600;
						font-size: 36rpx;
					}

					.curr {
						font-weight: 600;
						font-size: 40rpx;
						padding-right: 10rpx;
						margin-top: 16rpx;
					}
				}

				.card_2 {
					width: 30%;
					text-align: center;
					margin: 40rpx 0 39rpx 0rpx;
					background-color: #fff;
					border-radius: 20rpx;
					color: #2CB9A4;
					font-size: 26rpx;
					padding-top: 4rpx;
				}
			}
		}

		.listBox {
			width: 94%;
			margin: 30rpx auto;
			margin-top: 0;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				border: 2rpx solid #d9d9d966;
				box-shadow: 0 0 16rpx rgba(0, 0, 0, .1);
				margin: 20rpx auto;
				display: flex;
				justify-content: space-between;

				.list_l {
					width: 70%;
					display: flex;
					align-items: center;

					image {
						width: 84rpx;
						height: 84rpx;
						border-radius: 50%;
					}

					.list_l_r {
						font-size: 28rpx;
						font-weight: 400;
						margin-left: 20rpx;

						.name {
							height: 46rpx;
							line-height: 46rpx;
							display: flex;

							.icon {
								margin: 4rpx 4rpx 10rpx 14rpx;
								width: 30rpx;
								height: 30rpx;
								box-sizing: border-box;

								image {
									width: 30rpx;
									height: 30rpx;
								}
							}
						}
					}
				}

				.list_r {
					width: 24%;
					font-size: 24rpx;
					text-align: center;

					.time {
						height: 32%;
						color: #979797;
						margin-bottom: 14rpx;
					}

					.btn {
						background-color: #F1A547;
						color: #fff;
						border-radius: 30rpx;
						text-align: center;
						padding: 6rpx 16rpx;
					}

				}
			}
		}
	}
</style>